// 默认配置
axios.defaults.baseURL = 'http://47.94.46.113:7788'


// 请求拦截器
axios.interceptors.request.use(config => {
  let token = sessionStorage.getItem('token')
  if (config.path != '/user/login') {
    config.headers['Authorization'] = token
  }
  return config;
}, error => {
  return Promise.reject(error);
});


// 响应拦截器
axios.interceptors.response.use(response => {
  response = {
    ...response,
    data: response.data.data,
    statusText: response.data.message,
    timestamp: response.data.timestamp
  }
  return response;
}, error => {
  return Promise.reject(error);
});

function myget (url, data) {
  alert('123')
  return axios({
    url,
    method: 'get',
    params: data,
    timeout: 10000
  })
}

function post_string (url, data) {
  return axios({
    url,
    method: 'post',
    data: qs.stringify(data),
    timeout: 10000
  })
}

function post_json (url, data) {
  return axios({
    url,
    method: 'post',
    data,
    timeout: 10000
  })
}

